// 星星
import { _polygon } from './polygon.js'
import { starPoints } from '../algorithm/star.js'
import { polarPoints } from '../algorithm/polar.js'
import { _path2 } from './path2.js'
import { _g } from './svg.js'
import { PATH_MODE } from '../common/pathMode.js'
export const _star = (options = {}, props = {}) => {
    let { o, r, n, a, interiorPolygon = true } = options

    if (n > 4) {
        let points = polarPoints({ o, r, n, a })
        let ps = starPoints(points)

        let g = []
        if (interiorPolygon) {
            // ploygon
            g[g.length] = _path2({
                // ...options,
                points,
                pathMode: PATH_MODE.LINE_LOOP

            }, {
                ...props,
                strokeDasharray: 4
            })
        }


        // star
        g[g.length] = _path2({
            ...options,
            points: ps
        }, props)

        return _g(g)


    } else {

        let star = _polygon({
            ...options,
            transform: 'paritySort',
        }, props)
        return star
    }

}

